package com.sunxueqi.project.log.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.sunxueqi.framework.web.controller.BaseController;
import com.sunxueqi.framework.web.vo.ResponseData;
import com.sunxueqi.project.log.service.ILoginLogService;
import com.sunxueqi.project.log.vo.LoginLog;

import cn.hutool.core.util.StrUtil;
import io.swagger.annotations.Api;

@Api(tags="登录日志")
@RestController
@RequestMapping("/log/loginLog")
public class LoginLogController extends BaseController{

	@Autowired
	private ILoginLogService loginLogService;
	
	/**
	 * 获取登录日志列表
	 * @param LoginLog
	 * @return
	 */
	@GetMapping("/list")
	public ResponseData list(LoginLog LoginLog) {
		startPage();
		List<LoginLog> list = loginLogService.selectLoginLogList(LoginLog);
		return ResponseData.successTableData(list);
	}
	
	@DeleteMapping("/{ids}")
	public ResponseData delete(@PathVariable String ids) {
		String [] idArray = StrUtil.split(ids, ",");
		return super.getResponseDataRow(loginLogService.deleteLoginLogByIds(idArray));
	}
	
	/**
	 * 清除所有登录日志
	 * @return
	 */
	@DeleteMapping("/clean")
	public ResponseData cleanLog() {
		return super.getResponseDataRow(loginLogService.cleanLog());
	}
	
}
